<blockquote class="layui-elem-quote">
    <div class="layui-inline">
        <i class="layui-icon layui-icon-list layui-head-icon"></i>
        <span class="layui-font-16 layui-font-green">支付配置</span>
    </div>
</blockquote>
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">微信支付</li>
                <li>支付宝支付</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form">
                        <input type="hidden" name="id" value="{$row.1.id|default=''}">
                        <input type="hidden" name="type" value="1">
                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-inline">
                                <input type="number" name="sort" value="{$row.1.sort|default=0}" lay-verify="required" placeholder=""
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">APPID</label>
                            <div class="layui-input-block">
                                <input type="text" name="appid" lay-verify="required" placeholder="" autocomplete="off"
                                       value="{$row.1.config.appid|default=''}" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户号MCH_ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="mch_id" lay-verify="required" placeholder="" autocomplete="off"
                                       value="{$row.1.config.mch_id|default=''}"  class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户秘钥MCH_KEY</label>
                            <div class="layui-input-block">
                                <input type="text" name="mch_key" lay-verify="required" placeholder=""
                                       value="{$row.1.config.mch_key|default=''}"    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户证书SSL_KEY</label>
                            <div class="layui-input-block">
                                <textarea name="ssl_key" style="height: 500px" class="layui-textarea">{$row.1.config.ssl_key|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户证书SSL_CER</label>
                            <div class="layui-input-block">
                                <textarea name="ssl_cer" style="height: 500px" class="layui-textarea">{$row.1.config.ssl_cer|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="status" {if condition="$row.1.status==1"}checked {/if} value="1"  title="启用">
                                <input type="radio" name="status" {if condition="$row.1.status==0"}checked {/if} value="0" title="禁用">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="wechatForm">保存配置</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form">
                        <input type="hidden" name="id" value="{$row.2.id|default=''}">
                        <input type="hidden" name="type" value="2">
                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-inline">
                                <input type="number" name="sort" value="{$row.2.sort|default=0}" lay-verify="required" placeholder=""
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">APPID</label>
                            <div class="layui-input-block">
                                <input type="text" name="appid" lay-verify="required" placeholder="" autocomplete="off"
                                       value="{$row.2.config.appid|default=''}"     class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户公钥PRIVATE_KEY</label>
                            <div class="layui-input-block">
                                <textarea name="public_key" class="layui-textarea">{$row.2.config.public_key|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商户私钥PUBLIC_KEY</label>
                            <div class="layui-input-block">
                                <textarea name="private_key" class="layui-textarea">{$row.2.config.private_key|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="status" {if condition="$row.2.status==1"}checked {/if} value="1"  title="启用">
                                <input type="radio" name="status" {if condition="$row.2.status==0"}checked {/if} value="0" title="禁用">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="aliPayForm">保存配置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form;
        form.on('submit(wechatForm)', function (data) {
            $.post('/store/setting/payment/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg,{icon:1});
                    return false;
                }
                return layer.msg(res.msg, {icon: 2});
            });

            return false;
        });

        form.on('submit(aliPayForm)', function (data) {
            $.post('/store/setting/payment/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg,{icon:1});
                    return false;
                }
                return layer.msg(res.msg, {icon: 2});
            });

            return false;
        });


    });
</script>